package com.monco.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.monco.entity.GoodsOrder;
import com.monco.mapper.GoodsOrderMapper;
import com.monco.service.IGoodsOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
/**
* <p>
    *  服务实现类
    * </p>
*
* @author com/monco
* @since 2020-04-19
*/
@Service
public class GoodsOrderServiceImpl extends ServiceImpl<GoodsOrderMapper, GoodsOrder> implements IGoodsOrderService {

    @Resource
    private GoodsOrderMapper goodsOrderMapper;

    @Override
    public List<GoodsOrder> getGoodsOrderList(GoodsOrder goodsOrder) {
        return goodsOrderMapper.selectList(getWrapper(goodsOrder));
    }

    @Override
    public IPage<GoodsOrder> getGoodsOrderPage(IPage<GoodsOrder> page, GoodsOrder goodsOrder) {
        return goodsOrderMapper.selectPage(page, getWrapper(goodsOrder));
    }

    private QueryWrapper<GoodsOrder> getWrapper(GoodsOrder goodsOrder) {
        QueryWrapper<GoodsOrder> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("id");
        return queryWrapper;
    }
}
